home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Treccani Italiana Di Scienze Lettere Ed Arti
/
[Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso
/
pc
/
data
/
menu_dvd.swf
/
scripts
/
__Packages
/
HtmlTreeCellRenderer.as
< prev
next >
Wrap
Text File
|
2007-11-07
|
3KB
|
104 lines
class HtmlTreeCellRenderer extends mx.core.UIComponent
{
static var style_sheet = null;
static var USE_EMBEDDED_FONT = true;
static var ADD_DOT = false;
static var SPAN_BEFORE = "<span class=\'rowText\'>";
static var SPAN_AFTER = "</span>";
var previousLabel = null;
function HtmlTreeCellRenderer()
{
super();
if(HtmlTreeCellRenderer.ARRAY_ABBREVIAZIONI == undefined)
{
HtmlTreeCellRenderer.ARRAY_ABBREVIAZIONI = Array(" ill"," tab"," tabb"," fig"," cart"," segg"," diagr"," col"," mus");
}
}
function createChildren(Void)
{
if(HtmlTreeCellRenderer.CssUrl != undefined && HtmlTreeCellRenderer.style_sheet == null)
{
HtmlTreeCellRenderer.style_sheet = new TextField.StyleSheet();
HtmlTreeCellRenderer.style_sheet.load(HtmlTreeCellRenderer.CssUrl);
}
if(this.htmlComponent == undefined)
{
this.createLabel("htmlComponent",1);
}
this.htmlComponent.embedFonts = HtmlTreeCellRenderer.USE_EMBEDDED_FONT;
this.htmlComponent.html = true;
this.htmlComponent.border = false;
this.htmlComponent.multiline = false;
this.htmlComponent.wordWrap = false;
this.htmlComponent.selectable = false;
this.htmlComponent.background = false;
this.htmlComponent.styleSheet = HtmlTreeCellRenderer.style_sheet;
this.size();
}
function size(Void)
{
this.htmlComponent.setSize(this.__width - 2,this.__height);
}
function setValue(str, item, sel)
{
if(item == undefined)
{
this.htmlComponent.htmlText = this.HtmlFunction(str,"");
this.previousLabel = null;
return undefined;
}
var columnIndex = this.columnIndex;
var columnName = this.getDataLabel();
var htmlFunction = this.listOwner.getColumnAt(columnIndex).htmlFunction;
var label = this.HtmlFunction(str,columnName);
if(label != undefined)
{
if(label != this.previousLabel)
{
this.htmlComponent.htmlText = this.previousLabel = HtmlTreeCellRenderer.SPAN_BEFORE + label + HtmlTreeCellRenderer.SPAN_AFTER;
}
}
else
{
this.htmlComponent.htmlText = "";
}
}
function getPreferredHeight(Void)
{
if(this.owner == undefined)
{
return 18;
}
return this.owner.__height;
}
function HtmlFunction(inLabel, columnName)
{
var outV = inLabel;
outV = outV.split("<sub>").join("<sub>");
outV = outV.split("</sub>").join("</sub>");
outV = outV.split("<sup>").join("<sup>");
outV = outV.split("</sup>").join("</sup>");
outV = outV.split("\\[").join("");
outV = outV.split("\\]").join("");
if(outV.indexOf("<sup>") >= 0 || outV.indexOf("<sub>") >= 0)
{
outV = StringUtils.subSupFromHTML(outV);
}
if(HtmlTreeCellRenderer.ADD_DOT)
{
var len = outV.length;
var i = 0;
while(i < HtmlTreeCellRenderer.ARRAY_ABBREVIAZIONI.length)
{
if(outV.lastIndexOf(HtmlTreeCellRenderer.ARRAY_ABBREVIAZIONI[i]) == len - HtmlTreeCellRenderer.ARRAY_ABBREVIAZIONI[i].length)
{
outV += ".";
break;
}
i++;
}
}
return outV;
}
}